<%@ page language="java"  contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt"	uri="http://java.sun.com/jsp/jstl/fmt"%>

<!DOCTYPE html>
<html lang="zh-CN">
<head>

       <%@ include file="/WEB-INF/include/meta.jsp" %>
       <%@ include file="/WEB-INF/include/css.jsp" %>
      
       
  <link href="${ctx.resource}/css/select2.css" rel="stylesheet" >
  <link href="${ctx.resource}/css/select2-bootstrap.css" rel="stylesheet" >
  <title></title>
	
    <script type="text/javascript">   
  	var pageNo = Number(${pageNo}) ;
	var pageCount= Number(${pageCount});
	
	
	function search() {
		//把表单的数据进行序列化
		$.ajax({
			url:"${ctx}/student/showStuBypage",
			type:"POST",
			data:{name:$("#name").val(),schoolId:$("#schoolId").val(),grade:$("#grade").val(),cellPhone:$("#cellPhone").val(),subProId:$("#subProId").val(),pageNo:pageNo},
			dataType:"json",
			success:function(page){
				
				$("#pageCount").html(page.totalPage) ;
				$("#totalCount").html(page.total) ;
				$("#pageNo").html(pageNo);
				pageCount = Number(page.totalPage);
				var data1 ="" ;
				if(page.datas.length ==0 ){
				data1 += "<tr><td>没有相应数据</td></tr>" ;
				}
				for(var i=0;i<page.datas.length;i++){
				
					var len = page.datas[i].subProjects.length ;
					data1 += "<tr>" ;
					data1 +="<td>"+page.datas[i].uid+"</td>" ;
					data1 +="<td>"+page.datas[i].name +"</td>" ;
					data1 +="<td><a href='"+page.datas[i].school.schoolId +"/detail'>"+page.datas[i].school.schoolNAME+"</a></td>" ;
					data1 +="<td>"+page.datas[i].grade +"</td>" ;
					data1 +="<td>"+page.datas[i].email+"</td>" ;
					data1 +="<td>"+page.datas[i].cellPhone+"</td>" ;
					data1 +="<td>" ;
					 for(var j=0;j<len;j++){
                        data1 += "<a href='"+page.datas[i].subProjects[j].spid+"/detail'>"+page.datas[i].subProjects[j].name+"</a><br>" ;
  					}
					data1 +="</td>" ;
					data1 +="<td><a href='${ctx }/student/"+page.datas[i].uid+"/detail'>详情</a>&nbsp;<a onclick='{if(confirm('您确定删除此条信息吗?')){return true;}return false;}' href='${ctx}/student/"+page.datas[i].uid+"/delStu' >删除</a></td>" ;
  					data1 += "</tr>" ;
				}
				$("#quxiao").click() ;
				$("#shuju").html(data1) ;
			}
		});
	}
	function up(){
		if(pageNo>=pageCount){
			alert("这是最后一页") ;
			pageNo =pageCount ;
		}else{
			pageNo++ ;
			search() ;
		}
	}
	function down(){
		if(pageNo<=1){
			alert("这是第一页") ;
			pageNo =1 ;
		}else{
			pageNo--;
			search() ;
		}
	}
	function show(pageno){
		pageNo = Number(pageno) ;
		search() ;
	}
</script>
</head>

  <body>
  
  	<%@ include file="/WEB-INF/include/header.jsp" %>
	
	<%@ include file="/WEB-INF/include/menu.jsp" %>
	
	<div class="container main-content">
	
	     <div class="panel panel-default arizona-panel arizona-panel-layout">
		  
	           <div class="panel-heading">
                 <ol class="breadcrumb">
                        <li><a href="${ctx}/users">用户管理</a></li>  
                  </ol>
                  </div>
		  
	     <div class="panel-body">

        <!-- ================ submenu ================ -->
        
            <div class= "col-xs-2 arizona-panel-layout-left no-horizontal-padding">
                  <%@ include file="/WEB-INF/include/submenu.jsp" %>
            </div><!--Submenu End-->
    
              
        <!-- ================ right panel ================ -->
            
            <div class="col-xs-10 arizona-panel-layout-right">

                  <div class="arizona-breadcrumb-wrapper">
                        <div class="arizona-breadcrumb clearfix">
                              <h2>
                                    <i class="glyphicon glyphicon-sort-by-attributes"  title=""></i><span> 用户管理&nbsp;-&nbsp;学生管理</span>
                              </h2>
                        </div>
                  </div>
                        
                        
                  <div class="btn-toolbar pull-right">
                        <div class="btn-group">
                              <a class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" title="添加客户" data-toggle="modal" data-target="#userAdd" href="/arizona/customers/create">
                               <i class="glyphicon glyphicon-plus"></i> 添加学生用户
                              </a>
                               <a href="${ctx}/student/search" class="btn btn-default btn-shadow btn-shadow-default demo2do-btn" title="过滤查询" data-toggle="modal" data-target="#">
                  					<i class="glyphicon glyphicon-search"></i>&nbsp;查&nbsp;&nbsp;询
                				</a>
                        </div>
                  </div>
                    ${message}
                  
                   <!-- 模态框（Modal） Plus -->
                  <div class="modal fade " id="userAdd" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
                        <div class="modal-dialog demo2do-modal-dialog" style="width: 950px">
                              <div class="modal-content">
                                    <div class="modal-header arizona-breadcrumb no-bottom-border clearfix">
                                          <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                                          <h2>
                                                <i class="glyphicon glyphicon-plus"  title="student plus"></i><span> 用户管理&nbsp;-&nbsp;学生用户添加</span>
                                          </h2>
                                    </div>
                                    <form class="form-horizontal" action="${ctx}/student/add" method="post">
                                    <div class="modal-body">
                                          <div class="form-group demo2do-form-group">
                                                <label class="col-xs-2 control-label">姓名</label>
                                                <div class="pull-left width-30-percent">
                                                      <input class="form-control" type="text" value="" name="name"></input>
                                                      
                                                </div>
                                                <label class="col-xs-2 control-label">学校</label>
                                                <div class="pull-left width-30-percent">
                                                      <input class="form-control" type="text" value="" name="schoolId"></input>
                                                </div>
                                          </div>
                                           <div class="form-group demo2do-form-group">
                                                <label class="col-xs-2 control-label">年级</label>
                                                <div class="pull-left width-30-percent">
                                                      <input class="form-control" type="text" value="" name="grade"></input>
                                                </div>
                                                <label class="col-xs-2 control-label">Email</label>
                                                <div class="pull-left width-30-percent">
                                                      <input class="form-control" type="text" value="" name="email"></input>
                                                </div>
                                          </div>
                                          <div class="form-group demo2do-form-group">
                                                <label class="col-xs-2 control-label">电话</label>
                                                <div class="pull-left width-30-percent">
                                                      <input class="form-control" type="text" value="" name="cellPhone"></input>
                                                </div>
                                          </div>
                                    </div>
                                      <div class="modal-footer">
                                          <button type="reset" class="btn btn-default" data-dismiss="modal">取消</button>
                                   	       <button type="submit" class="btn btn-primary">添加</button>
                                  	  </div>
                                    </form>
                                  
                              </div> <!-- /.modal-content -->
                        </div> <!-- /.modal dialog -->
                  </div> <!--Modal fade End-->

                  <table class="table table-striped table-hover demo2do-table">
                        <thead>
                              <tr>
                                    <th>Uid</th>
                                    <th>Name</th>
                                    <th>School</th>
                                    <th>Grade</th>
                                    <th>Email</th>
                                    <th>Cellphone</th>
                                    <th>Project</th>
                                    <th>Edit</th>
                              </tr>
    					</thead>
                              <tbody  class="dele" id="shuju">
    <c:if test="${totalCount le 0 }">
		<tr>
		<td colspan="8">目前还没有用户数据</td>
		</tr>
	</c:if>
	<c:if test="${totalCount gt 0}">
		<c:forEach items="${list}" var="u">
		<tr>
									  <td>${u.uid }</td>
                                      <td>${u.name }</td>
                                      <td><a href="${u.school.schoolId }/detail">${u.school.schoolNAME }</a></td>
                                      <td>${u.grade }</td>
                                      <td>${u.email }</td>
                                      <td>${u.cellPhone }</td>
                                      <td>
                                      <c:forEach items="${u.subProjects}" var="pu">
                                      <a href="${pu.spid}/detail">${pu.name }</a><br>
                                      </c:forEach>
                                      </td>
		<td><a href="${ctx }/student/${u.uid }/detail">详情</a>&nbsp;<a onclick='{if(confirm("您确定删除此条信息吗?")){return true;}return false;}' href="${ctx }/student/${u.uid }/delStu" >删除</a></td>
		</tr>
		</c:forEach>
	</c:if>
                              </tbody>
                        <tbody>
           <table align='center' width="95%" height="41" ><tr><td >共<b><font color='FA8100' id="totalCount">${totalCount}</font>
</b>条信息&nbsp;&nbsp;<b><font color='FA8100'>${size }</font>
</b>条信息/页&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:show('1')"  style="text-decoration:none;">首页</a>
&nbsp;&nbsp;<a href="javascript:down()" style="text-decoration:none;">上一页</a>&nbsp;&nbsp;
<a href="javascript:up()"  style="text-decoration:none;">下一页</a>  
<a href="javascript:show('${pageCount } ')"  style="text-decoration:none;">尾页</a>&nbsp;&nbsp;&nbsp;&nbsp;页次：<strong><font color=FA8100 id='pageNo'>${pageNo}</font>/<font color=FA8100 id="pageCount">${pageCount }</font></strong>页
&nbsp;&nbsp;&nbsp;&nbsp;
</td></tr></table>
                        </tbody>

                  </table>

            </div><!--right panel End-->

        </div><!--Panel Body End-->

  	  </div><!--Panel layout End-->
  		
  	</div><!--Container End--> 

  	<%@ include file="/WEB-INF/include/footer.jsp" %>

  
  	<div><a class="btn btn-link" href="/manager"><strong>编辑</strong></a></div>
  	
  <%@ include file="/WEB-INF/include/script.jsp"%>
  <script src="${ctx.resource}/js/bootstrap-modal-trigger.js"></script>
  <script src="${ctx}/static/js/select2.min.js"></script>
  <script src="${ctx}/static/js/select2_locale_zh-CN.js"></script>
   
  </body>
  
</html>
